package com.ado.bazinga.core.controller;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *@author adonais
 *@date 2020年3月19日
 *@description IndexController.java
**/
@RestController
public class IndexController {
	
	@RequestMapping(value = "/")
	public String hello() {
		return "hello";
	}
	
	@GetMapping(value = "/test")
	public String test(HttpServletRequest request, HttpServletResponse response) {
		HttpSession session = request.getSession() ;
		session.setAttribute("hello", "world");
		System.out.println("sessionId1:" + session.getId());
		session.setAttribute("a", "aaa");
		System.out.println("sessionId2:" + session.getId());
		System.out.println("hello:" + session.getAttribute("hello"));
		System.out.println("a:" + session.getAttribute("a"));
//		Cookie cookie = new Cookie("user", session.getId());
//		response.addCookie(cookie);
		return "hello";
	}
	
	@GetMapping(value = "/testTwo")
	public String testTwo() {
		return null ;
	}

}
